package com.datamining.online

import java.util.Calendar

/**
  * Created by Administrator on 2017/5/9.
  */
/**
  * spark-test
  * MyTest
  *
  * @author Administrator kevin
  * @create 2017-05-09 15:13
  */
object MyTest {

  def compareDate(dateStr1: Any, dateStr2: Any): Int = {
    val dateStra = dateStr1.toString
    val calendar1: Calendar = Calendar.getInstance();
    calendar1.set(dateStra.split("-").apply(0).toInt, dateStra.split("-").apply(1).toInt, dateStra.split("-").apply(2).toInt)

    val dateStrb = dateStr2.toString
    val calendar2: Calendar = Calendar.getInstance();
    calendar2.set(dateStrb.split("-").apply(0).toInt, dateStrb.split("-").apply(1).toInt, dateStrb.split("-").apply(2).toInt)

    return ((calendar1.getTimeInMillis - calendar2.getTimeInMillis) / (1000 * 3600 * 24)).abs.toInt
  }

  def main(args: Array[String]): Unit = {
    //    val lll = List(1,2,3,4,5,6)
    //    lll.splitAt(3)._1.foreach(x => println(x))
    //
    //    println(lll.apply(0))

    println(compareDate("2017-05-08", "2017-05-09"))


    //    val list = List()
    //    for (i <- 0 to 10){
    //
    //      println(i)
    //    }
  }
}
